package com.xfp.controller;

import com.xfp.result.Result;
import com.xfp.pojo.dto.LoginDto;
import com.xfp.pojo.vo.LoginUserVo;
import com.xfp.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/api/user-service/user")
@Api(tags = "用户接口")
public class LoginController {

    @Autowired
    private UserService userService;

    /**
     * 登录方法
     * @param dto
     * @return
     * @throws Exception
     */
    @PostMapping("/login")
    @ApiOperation("用户登录")
    public LoginUserVo login(@RequestBody LoginDto dto) throws Exception {
        log.info("登录接口正常执行：{}",dto);
        LoginUserVo vo = userService.login(dto);
        log.info("返回的登录信息为：{}",vo);
       return vo;
    }


}
